<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>

// var namea = "The Window";

// 　　var object = {
// 　　　　namea : "My Object",

// 　　　　getNameaFunc : function(){
// 　　　　　　return function(){
// 　　　　　　　　return this.namea;
// 　　　　　　};
// 　　　　}
// 　　};

// console.log(object.getNameaFunc()());


Array.prototype.qmap = function (fn) {
    
    console.log(this, '<---this');
    var arr = this;

    var temp = [];

    for (var i = 0 ; i< arr.length; i++) {
        temp.push(fn(arr[i],i));
    }

    return temp;
}


let arr = [1,2,3];
var aa = arr.qmap(function (v,k) {
    console.log(v,k);

    return v * 2
}, 'xxx');
console.log(aa, '<---aa');

/**
 * 
 * /

 function getRandomArrayElements(arr, count) {
    var shuffled = arr.slice(0), i = arr.length, min = i - count, temp, index;
    while (i-- > min) {
        index = Math.floor((i + 1) * Math.random());
        temp = shuffled[index];
        shuffled[index] = shuffled[i];
        shuffled[i] = temp;
    }
    return shuffled.slice(min);
}


var items = ['1','2','4','5','6','7','8','9','10'];
console.log( getRandomArrayElements(items, 4) );
*/


    </script>
</body>
</html>

